<template>
	<view class="p-bot40">
		<status-bar title="配置收益"></status-bar>

		<view class="list" v-for="item in pageData" :key="item.goods_id">
			<view class="goodsInfo">
				<text class="black size30 ellipsis_2">{{item.goods_name}}</text>
				<text class="color_99 size30 m-top20">￥{{item.goods_price}}</text>
			</view>
			<view class="Adjustprice">
				<u-number-box v-model="item.income" integer min="0" :max="item.maxIncome"
					@change="valChange($event,item,1)"></u-number-box>
				<view class="rows m-top10">
					<u-slider v-model="item.income" :activeColor="color" inactiveColor="#c0c4cc" min="0"
						:max="item.maxIncome" height="100" @change="valChange($event,item,2)" :blockColor="color"
						blockSize="12" :blockStyle="blockStyle"></u-slider>
				</view>
			</view>
		</view>

		<emptys v-if="!pageData.length" title="暂无相关内容~"></emptys>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				uid: '',
				pageData: [],
				value: 0,
			}
		},
		onLoad(opt) {
			if (opt.id) this.uid = opt.id
			this.showDirectSalesMemberGoodsList()
		},
		methods: {
			showDirectSalesMemberGoodsList() {
				this.$http.post({
					url: '/osmxcxApi/showDirectSalesMemberGoodsList',
					data: {
						uid: this.uid
					}
				}).then(res => {
					if (res.code != 100) return this.$Toast(res.msg)
					const result = res.data || []
					this.pageData = result
				})
			},
			valChange(e, Item, num) {
				let income;
				income = num == 1 ? e.value : e
				this.$showLoading('')
				this.$http.post({
					url: '/osmxcxApi/editDirectSalesMemberGoodsIncome',
					data: {
						uid: this.uid,
						goods_id: Item.goods_id,
						income
					}
				}).then(res => {
					this.$hideLoading()
					if (res.code != 100) return this.$Toast(res.msg)
				})

			}
		},
		computed: {
			...mapState(['color']),
			blockStyle() {
				return {
					width: '10rpx',
					height: '10rpx',
					color: this.color
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: $page;
	}
</style>
<style lang="scss" scoped>
	.list {
		width: 710rpx;
		margin: 24rpx auto 0;
		background-color: #ffffff;
		padding: 20rpx 0 20rpx 20rpx;
		border-radius: 10rpx;
		display: flex;
		align-items: center;

		.goodsInfo {
			flex: 1;
			display: flex;
			flex-direction: column;
		}

		.Adjustprice {
			width: 360rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
	}
</style>